<?php
session_start();
require('sqlconnect.php');
if (isset($_GET['logout'])) {
    session_destroy();
    setcookie("user", "", time() - 3600);
    header("Location:HomePage.php");
}
?>

<html>
    <head>       
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Welcome Froshies!</title>
        <link rel="stylesheet" href="style.css" type="text/css" media="all" />
        <script src="jquery-1.7.2.min.js" type="text/javascript"></script>
        <script type ="text/javascript" src="login.js"></script>


        <script type ="text/javascript" src="menujs.js"></script>

        <script type ="text/javascript" src="Galleryjs.js"></script>

    </head>
    <body onload="galleryrun()">


        <div id="fb-root"></div>
        <script>(function(d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) return;
            js = d.createElement(s); js.id = id;
            js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
            fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));</script>

        <div id="wrap">  
            <div id="header">
                <div>

                    <a href="HomePage.php"><img id="imgheader"></a>

                </div>
            </div>
          <div id="menu">
                 <ul id="nav">
 


                    <li><a href="HomePage.php" title="Home">Home</a></li>		
                    <li><a href="Campus.php"title="Campus">Campus</a></li>
                    <li><a href="Gallery.php" title="Gallery">Gallery</a></li>
					<?php if ($_SESSION['type'] == 1) { echo '<li><a href="Upload.php" title="Upload">Upload Photo</a></li>'; } ?>
                    <li><a href="#" title="Sponsors">Sponsors</a></li>
                    <li onmouseover="submenushow()" onmouseout="submenuhide()"><a href="LAMB.php" title="Lamb">Lasallian Ambassadors</a></li>
			
		    
                    <li><a href="#" title="FAQ">FAQ</a></li>  </ul>
            
			<ul id="submenu" onmouseover="submenushow()">
                                <li><a href="#">Human Reasource Management<br> and Developement </a></li><br>
                                <li><a href="#">Marketing and Publicity</a></li><br>
                                <li><a href="#">Operations and Logistics</a></li><br>
				<li><a href="#">Research and Documents</a></li><br>
                        </ul>

</div>


            <div id="content">



                <div class="article">


                    <div class="inside">


                        <?php
                        // Grab the data from our people table
                        $sql = "select * from images WHERE imgID='" . $_GET['imgID'] . "'";
                        $result = mysql_query($sql) or die("Could not access DB: " . mysql_error());

                        while ($row = mysql_fetch_assoc($result)) {
                            echo "<div id=\"largepic\" >";
                            echo "<img width=\"800\" src=\"blockpics/" . $row['filename'] . "\" alt=\"\" />";
                            echo "</div>";
                        }
                        ?>
                        <div id="commentdiv">
                            <h2>Comments:</h2>

                            <?php
                            $sql = "SELECT * FROM comments WHERE imgID=" . $_GET['imgID'] . " ORDER BY datetime";
                            $result = mysql_query($sql);
                            while ($rows = mysql_fetch_array($result)) {

                                echo '<p id="comment">';
                                echo $rows['username'];
                                echo ' said at:' . $rows['datetime'] . ' <br/>';
                                echo $rows['comments'];
                                echo '</p>';
                            }
                            ?></p>

                            <h3 style="color:white;">Add a Comment as <?php echo $_SESSION['username']; ?></h3>
                            <form  method="post" action="add_comment.php?imgID=<?php echo $_GET['imgID']; ?>&username=<?php echo $_SESSION['username']; ?>">
                                <textarea rows="5" name="comments" id="comments" 	></textarea><br/>
                                <input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" />

                            </form>
                        </div>                                
                    </div>                   

                </div>



            </div>





            <div id="sidebar">


                <div class="widget" style="padding-bottom: 20px;">

                    <div class="inside">
<?php require("session.php"); ?>
                    </div>

                </div>
            </div>





            <div class="fb-like-box" data-href="http://www.facebook.com/pages/Lasallian-Ambassadors/226171910194" data-width="200" data-height="240" data-show-faces="true" data-stream="false" data-header="true"></div>

        </div>








    </div>
</body>
</html>